package com.wswy.wzcx.ui.activity;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.annotation.StringRes;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ImageView;
import android.widget.TextView;
import com.che.libcommon.ui.BaseActivity;
import com.che.libcommon.ui.loading.LoadingActivity;
import com.wswy.wzcx.R;

/**
 * 必须引入 layout_app_title.xml
 */
public class SampleBaseActivity extends LoadingActivity {

  protected TextView tvTitle;
  protected ImageView imgBack;

  @Override
  protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
  }

  @Override
  protected int getRootLayoutViewId() {
    return 0;
  }

  @Override
  protected int getLoadingFrameId() {
    return 0;
  }

  protected void setAppTitle(@StringRes int titleRes){
    setTitle(getString(titleRes));
  }

  protected void setAppTitle(String title){
    if(tvTitle == null){
      tvTitle = findViewById(R.id.tv_title);
    }
    tvTitle.setText(title);


    if(imgBack == null){
      imgBack = findViewById(R.id.img_back);
    }

    imgBack.setOnClickListener(new OnClickListener() {
      @Override
      public void onClick(View v) {
        finish();
      }
    });

  }


  @Override
  public LoadingConfigure getConfigure() {
    return null;
  }

  @Override
  protected boolean needLoading() {
    return false;
  }
}
